<form method="post" id="OssFormData" name="form1">
    <div class="hDiv" id="oss">
        <div class="hDivBox">
            <table cellspacing="0" cellpadding="0" style="width: 100%">
                <thead>
                <tr>
                    <th class="sign w10" axis="col0">
                        <div class="tc"></div>
                    </th>
                    <th abbr="article_title" axis="col3" class="w10">
                        <div id="anchor-sms" class="tc">
                            {notempty name="$is_eyou_authortoken"}
                                <i class="anchor-icon anchor-icon-biao" title="限商业授权以上可用"></i>
                            {/notempty}
                            OSS配置
                        </div>
                    </th>
                    <th abbr="ac_id" axis="col4">
                        <div class=""></div>
                    </th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
    <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label for="oss_switch">开启OSS</label>
            </dt>
            <dd class="opt">
                <div class="onoff">
                    <label for="switch1" class="cb-enable  {if condition="isset($oss.oss_switch) && $oss.oss_switch eq 1"}selected{/if}">开启</label>
                    <label for="switch0" class="cb-disable {if condition="!isset($oss.oss_switch) || $oss.oss_switch eq 0"}selected{/if}">关闭</label>
                    <input type="radio" id="switch1" name="oss_switch" value="1" {if condition="isset($oss.oss_switch) && $oss.oss_switch eq 1"}checked="checked"{/if}>
                    <input type="radio" id="switch0" name="oss_switch" value="0" {if condition="!isset($oss.oss_switch) || $oss.oss_switch eq 0"}checked="checked"{/if} >
                </div>
                <p class="notic">是否开启OSS，开启时上传图片自动同步到OSS</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="oss_key_id"><em>*</em>KeyId</label>
            </dt>
            <dd class="opt">
                <input id="oss_key_id" name="oss_key_id" value="{$oss.oss_key_id|default=''}" class="input-txt" type="text" />
                <p class="notic">OSS对象存储的AccessKeyId</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="oss_key_secret"><em>*</em>KeySecret</label>
            </dt>
            <dd class="opt">
                <input id="oss_key_secret" name="oss_key_secret" value="{$oss.oss_key_secret|default=''}" class="input-txt" type="text" />
                <p class="notic">OSS对象存储的AccessKeySecret</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="oss_endpoint"><em>*</em>Endpoint</label>
            </dt>
            <dd class="opt">
                <input id="oss_endpoint" name="oss_endpoint" value="{$oss.oss_endpoint|default=''}" class="input-txt" type="text" />
                <p class="notic">OSS对象存储的Endpoint，比如 oss-cn-beijing.aliyuncs.com</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="oss_bucket"><em>*</em>Bucket</label>
            </dt>
            <dd class="opt">
                <input id="oss_bucket" name="oss_bucket" value="{$oss.oss_bucket|default=''}" class="input-txt" type="text" />
                <p class="notic">OSS对象存储的Bucket名称</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="oss_domain"><em>*</em>访问域名</label>
            </dt>
            <dd class="opt">
                <input id="oss_domain" name="oss_domain" value="{$oss.oss_domain|default=''}" class="input-txt" type="text" />
                <p class="notic">Bucket绑定的域名，请绑定并解析后填入，否则无法正常查看图片</p>
            </dd>
        </dl>
        <dl class="row">
            <div class="bot" style="padding-bottom:0px;">
                <a href="JavaScript:void(0);" onclick="CheckOssForm();" class="ncap-btn-big ncap-btn-green">确认提交</a>
                &nbsp;<a href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=9318','OSS配置教程')" style="font-size: 12px;padding-left: 10px;position:absolute;top: 42px">不会配置？</a>
            </div>
        </dl>
    </div>
</form>
<script type="text/javascript">
    function CheckOssForm() {
        if (!$('#oss_key_id').val()) {
            layer.msg('请填写 AccessKeyId');
            $('#oss_key_id').focus();
            return false;
        }
        if (!$('#oss_key_secret').val()) {
            layer.msg('请填写 AccessKeySecret');
            $('#oss_key_secret').focus();
            return false;
        }
        if (!$('#oss_endpoint').val()) {
            layer.msg('请填写 Endpoint');
            $('#oss_endpoint').focus();
            return false;
        }
        if (!$('#oss_bucket').val()) {
            layer.msg('请填写 Bucket');
            $('#oss_bucket').focus();
            return false;
        }
        if (!$('#oss_domain').val()) {
            layer.msg('请填写 访问域名');
            $('#oss_domain').focus();
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            url: "{:url('System/oss', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#OssFormData').serialize(),
            success: function(res){
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {icon: 1, time: 1000});
                    return false;
                } else {
                    var icon = 2;
                    try{
                        if (res.data.icon) {
                            icon = res.data.icon;
                        }
                    }catch(e){}
                    layer.alert(res.msg, {icon: icon, title:false});
                    return false;
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorMsg(e.responseText);
                return false;
            }
        });
    }
</script> 